# encoding:utf-8
# user: ares at 18-9-5
# 用POST方式提交表单爬取数据

import requests
from bs4 import BeautifulSoup
import json

url='http://oa.ysstech.com:5888/shr/dynamic.do?method=getListData'

cookie='EASSESSIONID=-1341187657; NAPRoutID=-1341187657; JSESSIONID=wKhJARcOW492p-SbTIyANkzpphQiNSP4BE4A'

header={
    'User-Agent':'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0',
    'Accept':'application/json, text/javascript, */*; q=0.01',
    'Connection':'keep-alive',
    'Referer':'http://oa.ysstech.com:5888/shr/dynamic.do?uipk=com.kingdee.eas.hr.ats.app.AtsOverTimeBillForm&inFrame=true&fromHeader=true',
    'Host':'oa.ysstech.com:5888',
    'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
    'Cookie':cookie
}

files={
'_search': 'false',
'nd': '1536129834818',
'rows': '50',
'page': '1',
'sidx': '',
'sord': 'asc',
'componentID': 'grid',
'query': 'com.kingdee.eas.hr.ats.app.AtsOverTimeBillQuery',
'filterItems': "entries.otDate >= '2018-07-01'  and entries.createTag = 1",
'sorterItems': 'entries.id',
'filter': '',
'custom_params': '{"inFrame":"true","uipk":"com.kingdee.eas.hr.ats.app.AtsOverTimeBillList","billId":""}',
'keyField': 'id',
'columnModel': 'number,person.name,entries.startTime,entries.endTime,entries.restTime,entries.applyOTTime,otCompens.name,otReason.name,otType.name,billState,description,entries.createTag,billSubmitType,entries.id,person.id,id,',
'uipk': 'com.kingdee.eas.hr.ats.app.AtsOverTimeBillList'
}
#result=json.loads(files)

#wbdata=requests.get(url,headers=header).text
wbdata=requests.post(url=url,data=files,headers=header).text

datas=json.loads(wbdata)

data=datas['rows']

for d in data:
    print(d)

